from pymongo import MongoClient
import os
import json
import pymongo
client = MongoClient(port=27017)
db=client['tiktok_p2_1']
obj={
    '_id':'',
    'frame_level':{'f0':{'text':{},'img':{},'audio':{}},
                   'f1':{'text':{},'img':{},'audio':{}},
                   'f2':{'text':{},'img':{},'audio':{}},
                   'f3':{'text':{},'img':{},'audio':{}},
                   'f4':{'text':{},'img':{},'audio':{}},
                   'f5':{'text':{},'img':{},'audio':{}},
                   'f6':{'text':{},'img':{},'audio':{}},
                   'f7':{'text':{},'img':{},'audio':{}},
                   'f8':{'text':{},'img':{},'audio':{}},
                   'f9':{'text':{},'img':{},'audio':{}}
    },
    'video_level':{
    }
}
# add=[]
# for ht in os.listdir('E:\\tiktok_new\\video\\'):
#     add.append(ht)
collist=['gaminglife', 'whatilearned', 'happyholi', 'stpatricksday', 'ontherunway', 'joblife', 'homecooked', 'tiktokcars', 'gettheretogether', 'zodiacsign', 'hellowinter', 'healthyheart', 'tiktokfood', 'petsontiktok', 'homecook', 'timewarpwaterfall', 'tiktokdiy', 'graphicdesign', 'holidaycrafts', 'foodtiktok', 'emophase', 'neontwin', 'tiktokwildlifeday', 'nflplayoffs', 'smallbusiness', 'needtoknow', 'superbowllv', 'mifamilia', 'nbaallstar', 'hyperfixated', 'couplethings', 'kissyourpet', 'greenscreenscan', 'tabletop', 'wildanimals', 'stemlife', 'easyrecipe', 'fallguysmoments', 'inkdrawing', 'gamenight', 'planttiktok', 'yellow', 'imaghost', 'mlkday', 'perfectmatch', 'homecafe', 'siblinggoals', 'whenwomenwin', 'promszn', 'halloweenlook', 'christmas2020', 'diyprojects', '2018vs2021', 'tiktokfashionmonth', 'theatrekids', 'mystyle', 'artmas', 'wrestlemania', 'cleaningtiktok', 'mypfp', 'holidaymusic', 'beautyhack', 'carsoftiktok', 'moneytok', 'homediy', 'holidaysourway', 'ratatouillemusical', 'happyhanukkah', 'colddays', 'thriftflip', 'carhacks', 'familyimpression', 'aprilfools', 'falldiy', 'recordsday', 'givingthanks', 'cartiktok', 'fallfashion', 'homeimprovement', 'crowdcheers', '2021affirmations', 'mobilegame', 'problemsolved', 'herstory', 'weirdpets', 'nbaisback', 'haventseen', 'baseballtiktok', 'ohno', 'clingypet', 'fantheory', 'coversforlovers', 'homemade', 'learnwithme', 'happyeaster', 'womeninstem', 'seashanty', 'somethingyoulearned', 'whenwewereyounger', 'vinylclub', 'productivity', 'animation', 'yearontiktok', 'coldweather', 'rareaesthetic', 'sidetable', 'onlinedating', 'puppybowl', 'perfectdrink', 'colorblast', 'sheesh', 'roomtour', 'thriftshop', 'sfxmakeup', 'housetour', 'perfectgifts', 'myrecommendation', 'nowruz', 'weekendvibes', 'givingszn', 'royalrumble', 'neonshadow', 'springvibes', 'learnontiktok', 'defrosting', 'doctorsoftiktok', 'healthycooking', 'dailyvlog', 'stylehacks', 'nhlfaceoff', 'ecohacks', 'catchphrases', 'wishlist', 'personalfinance', 'meditation101', 'diceroll', 'youwantmore', 'wordsofwisdom', 'upcycling', 'stepbystep', 'wip', 'baseballisback', 'welldone', 'onhold', 'unwrapthedeals', 'halloweenishere', 'notaperfectperson', 'typing', 'foodie', 'beautyhacks', 'inspirationalquotes', 'snowstorm', 'tipsandtricks', 'puppiesonly', 'fanedit', 'howbizarre', 'marchmadness', 'myhaul', 'meleaving', 'blackandproud', 'dayandnight', 'veteransday', 'fitnesslife', 'readysetshop', 'earthday', 'valentinesdiy', 'nonuancenovember', 'pleasedontgo', 'amongus', 'imbusyrightnow', 'naturescereal', 'holidaytiktok', 'itwasntaphase', 'winterfashion', 'melaninmagic', 'whereilive', 'laughingduet', 'winterfit', 'groupchat', 'myhobby', '90saesthetic', 'nowlookatthis', 'inlove', 'projectcar', 'relationshipstorytime', 'happyhalloween', 'yougotthis', 'galentinesday', 'welcome2021', 'motivationmonday', 'festivefashion', 'visionboard', 'comfortfood', 'givethanksnotpranks', 'fetapasta', 'horrortok', 'bekind', 'inverted', 'careeradvice', 'growupwithme', 'hellospring', 'feelinggood', 'sabiasque', 'isthisavailable', 'workingathome', 'goodmorning', 'bye2020', 'athletesoftiktok', 'takeabite', 'easydiy', 'watchmegrow', 'holidaydecor', 'seitan', 'myroutine', 'foodontiktok', 'holidaytreats', 'dinnerparty', 'gamergoals', 'tiktokfitness', 'vaccinatedfor', 'wintersports', 'sheearnedit', 'transvisibilityday', 'familyrecipe', 'cozyathome', 'gamingtiktok', 'raisedby', 'thankstoher', 'thinkingabout', 'healthyliving', 'plantparent', 'hereforrmhc', 'oscars', 'valentinesday', 'makeitvogue', 'lifestyle', 'happyholidays', 'lunarnewyear', 'olympicscountdown', 'bakingszn', 'competitivegaming', 'timewarpjump', 'homeproject', 'ourtype', 'cleantok', 'fitnessroutine', 'glasspainting', 'holidayvibes', 'blackcreatives', 'makeblackhistory', 'nativefamily', 'nbadraft', 'lovestory', 'dramaticmoments', 'tortillatrend', 'bakedoats', 'winterbeautytips', 'interiordesign', 'lookbook', 'holidaycountdown', 'ootd', 'selfimprovement', 'albumcover', 'passover', 'homebusiness', 'guitartok', 'tiktoktailgate', 'mycostume', 'science101', 'gamingsetup', 'homeoffice', 'springoutfit', 'rnbvibes', 'autismawareness', 'roundofapplause', 'passingthephone', 'tiktoktutorial', 'thrifting', 'songfacts', 'loveyourinsecurities', 'skincare101']
for hashtag in collist:
    i=0
    scss=0
    fl=0
    hashtag=hashtag.replace('#','').lower()
    for fname in os.listdir('F:\\tiktok_new\\video_1\\'+hashtag+'\\'):
        id=fname.replace('.mp4','')
        temp=obj
        temp['_id']=id
        try:
            db[hashtag].insert_one(temp)
            scss+=1
        except pymongo.errors.DuplicateKeyError:
            fl+=1
        i+=1
    print(hashtag,scss,fl)

